package com.xintouyun.medicine.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xintouyun.medicine.entity.Goods;
import com.xintouyun.medicine.service.GoodsService;
import com.xintouyun.medicine.service.impl.GoodsServiceImpl;

@WebServlet("/detailgoods")
public class DetailGoodsServlet extends HttpServlet{
	@Override
    public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{

    	String id = request.getParameter("gid");
    	Integer gid = Integer.parseInt(id);
    	
    	GoodsService goodsService = new GoodsServiceImpl();
    	
    	Goods theGoods = goodsService.get(gid);
    	
    	request.setAttribute("theGoods", theGoods);
    	request.getRequestDispatcher("detail.jsp").forward(request, response);
    }
	
	@Override
    public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{
    	this.doGet(request, response);
    }
}
